programming4us
           
 
 
Programming

Programming Windows Azure : Table Operations - Creating Entities

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/21/2010 11:31:00 AM

Creating entities is similar to the process for creating tables. You can create an entity by POSTing to the URL for the table. For example, the following code shows the HTTP request-response traffic for creating a simple contact. Note that the properties of the entity are encoded using Atom. You annotate specific types (such as dates/times) with the right Entity Framework attribute.

POST /ContactTable HTTP/1.1
x-ms-date: Tue, 21 Apr 2009 06:39:17 GMT
Authorization: SharedKeyLite sriramk:hdSwtwXUeuDrY2LTvsySw8oD0hcCwKpbqeLL4IbaBJs=
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8
Content-Type: application/atom+xml
Host: sriramk.table.core.windows.net
Content-Length: 719

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d=http://schemas.microsoft.com/ado/2007/08/dataservices
xmlns:m=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata
xmlns="http://www.w3.org/2005/Atom">

<title />
<updated>2009-04-21T06:39:17.3098Z</updated>
<author>
<name />
</author>
<id />
<content type="application/xml">
<m:properties>
<d:Address>One Infinite Loop</d:Address>
<d:Name>Steve Jobs</d:Name>
<d:PartitionKey>a844fa27-7ae2-4894-9cc6-dd0dbdcd5ec4</d:PartitionKey>
<d:RowKey m:null="false" />
<d:Timestamp m:type="Edm.DateTime">0001-01-01T00:00:00</d:Timestamp>
</m:properties>
</content>
</entry>


If the entity is created successfully, the server sends down an HTTP 201 message, an ETag, and a copy of the entity.

Of course, all of this is just ADO.NET Data Services plumbing. In .NET code, you typically go through the following steps:

  1. Write your data model classes. In this case, you already wrote these when you created your table.

  2. Create an instance of the DataServiceContext-derived type to which to add local changes.

  3. Call SaveChanges to upload changes to the cloud.

Example 1 shows how you can write code to add an entity to ContactTable. This produces the same HTTP traffic as shown earlier.

Example 1. Adding an entity
           var account =
CloudStorageAccount.Parse(ConfigurationSettings.AppSettings
["DataConnectionString"]);

var svc = new TestDataServiceContext(account.TableEndpoint.ToString(),
account.Credentials);
//We don't need to specify PartitionKey since it is generated for us in Contact
//constructor
var contact = new Contact(){
Name="Steve Jobs",
Address="One Infinite Loop"
};
svc.AddObject("ContactTable", contact);
svc.SaveChanges();


What is happening here under the covers? Think of DataServiceContext as a sync engine. It accumulates changes on the client, and sends them in one shot to the server when SaveChanges is called. In this case, you’re adding an object to a table (entityset), but the same holds true when you’re updating/deleting entities, too.

Other -----------------
- Programming Windows Azure : Table Operations - Creating Tables
- iPad Development : Document Management (part 2)
- iPad Development : Document Management (part 1)
- iPad Development : The Split View Concept
- jQuery 1.3 : Developing plugins - Adding new shortcut methods
- jQuery 1.3 : Developing plugins - DOM traversal methods
- Using Cloud Services : Exploring Online Planning and Task Management
- Using Cloud Services : Exploring Online Scheduling Applications
- Using Cloud Services : Exploring Online Calendar Applications
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 3)
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 2)
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 1)
- Cloud Security and Privacy : Data Security and Storage
- iPad SDK : Working with Documents - Desktop Synchronization
- Required Project Images for iPad Apps
- iPhone SDK : GameKit Voice Chat
- iPhone SDK : Creating Basic GameKit Services (part 2) : Sending and Receiving Data
- iPhone SDK : Creating Basic GameKit Services (part 1)
- iPad : Navigating with Maps
- Adding iPad to the Mix
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us